/*
 * @Autor: taobo
 * @Date: 2020-06-11 20:55:54
 * @LastEditTime: 2020-06-11 21:39:26
 * @desc: 重点是记住三角形面积公式= fabs(ab.x*bc.y - ab.y*bc.x)/2.0f
 */ 
#include <iostream>
#include <vector>
#include <cmath>
#define ABS_FLOAT_0 0.000001
using namespace std;

struct point{ //点坐标
    float x;
    float y;
    point()=default;
    point(int a,int b):x(a),y(b){}
};

class Triangle{
private:
    point A,B,C;
public:
    void set_point(float x1,float y1,float x2,float y2,float x3,float y3){
        A.x = x1, A.y = y1;
        B.x = x2, B.y = y2;
        C.x = x3, C.y = y3;
    }
    float gettriangle_area(const point& a,const point& b,const point& c){
        point ab(a.x-b.x,a.y-b.y);
        point bc(b.x-c.x,b.y-c.y);
        return fabs(ab.x*bc.y-ab.y*bc.x)/2.0f;
    }
    bool Isintriangle(const point &p){
        float sabc,sabp,sacp,sbcp;
        sabc = gettriangle_area(A,B,C);
        sabp = gettriangle_area(A,B,p);
        sacp = gettriangle_area(A,C,p);
        sbcp = gettriangle_area(B,C,p);
        float s = sabp+sacp+sbcp;
        if(sabc-s>-ABS_FLOAT_0 && sabc-s<ABS_FLOAT_0){
            return true;
        }else{
            return false;
        }
    }
};

int main()
{
    Triangle obj;
    obj.set_point(10,1,-10,0,0,20);
    bool res = obj.Isintriangle(point(0,4));
    cout << std::boolalpha << res <<'\n';
    return 0;
}